import java.io.File;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class J1 {
	public static void main(String[] args) throws Exception {

		SAXReader saxrader = new SAXReader();
		Document doc = saxrader.read(new File("products.xml"));
		Element toot = doc.getRootElement();
		System.err.println("根目录名称" + toot.getName());
		List<Element> list = doc.selectNodes("/shop/product");
		for (Element e : list) {
			boolean f = new Boolean(e.attributeValue("diacount"));
			String addr = e.attributeValue("factotyaddr");
			Element eno = (Element) e.selectNodes("itemno").get(0);
			String pno = eno.getText();
			String a = e.selectSingleNode("name").getText();
			String b = e.selectSingleNode("price").getText();
			double c = Double.parseDouble(b);
			int stock = Integer.parseInt(e.selectSingleNode("stockcount").getText());
			String d = e.selectSingleNode("unit").getText();
			System.out.println("名称" + a + "价格" + b + "编号" + pno + "折扣？？" + f + "产地" + pno + "库存" + stock + d);
		}
	}
}
